package com.example.dangerouscargodriver.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.example.dangerouscargodriver.R;
import com.example.dangerouscargodriver.utils.AppManager;
import com.example.dangerouscargodriver.widget.ActionBar;

public class EnterPlatformPersonalSuccessActivity extends AppCompatActivity implements View.OnClickListener {

    private ActionBar mActionBar = null;
    private TextView mReturnHome = null;
    private TextView mSeeDetail = null;

    private String mTid = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_enter_platform_personal_success);

        mTid = getIntent().getStringExtra("tid");

        mReturnHome = findViewById(R.id.tv_return_home);
        mReturnHome.setOnClickListener(this);
        mSeeDetail = findViewById(R.id.tv_see_detail);
        mSeeDetail.setOnClickListener(this);

        mActionBar = findViewById(R.id.actionBarEnterPlatformStepThree);
        mActionBar.setOnBackClickListener( new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                AppManager.getAppManager().finishActivity();
                AppManager.getAppManager().finishActivity();
                finish();
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            AppManager.getAppManager().finishActivity();
            AppManager.getAppManager().finishActivity();
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.tv_return_home){
            AppManager.getAppManager().finishActivity();
            AppManager.getAppManager().finishActivity();
            finish();
        }
        else if(v.getId() == R.id.tv_see_detail){
            AppManager.getAppManager().finishActivity();
            AppManager.getAppManager().finishActivity();
            finish();
            Intent intent = new Intent(this, PersonalTruckDetailInfoActivity.class);
            if(mTid != null){
                intent.putExtra("tid", mTid);
            }
            startActivity(intent);
        }
        else{

        }
    }
}